// [[ OnflowGenerator File UUID: 0eb7b3abfe6e42c18cc3d310511b75b0  ]]
package com.itdct.onflow.system.role.controller

import com.itdct.onflow.core.type.*
import com.itdct.onflow.core.vo.KeyLabelValueVo
import com.itdct.onflow.core.vo.RespPageVo
import com.itdct.onflow.core.vo.RespVo
import com.itdct.onflow.system.common.base.BaseSysController
import com.itdct.onflow.system.role.qo.SysRoleComponentEditQo
import com.itdct.onflow.system.role.qo.SysRoleComponentSearchQo
import com.itdct.onflow.system.role.service.SysRoleComponentService
import com.itdct.onflow.system.role.vo.SysRoleComponentDetailVo
import com.itdct.onflow.system.role.vo.SysRoleComponentListVo
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.*

/**
 * @author DCTANT
 * @date 2025-09-17 16:36:22
 * @version 1.0
 * @description 角色组件关联接口控制
 */
@Tag(name = SysRoleComponentController.moduleName)
@RestController
@RequestMapping(value = ["/sysRoleComponent"], produces = [MediaType.APPLICATION_JSON_VALUE], method = [RequestMethod.POST])
class SysRoleComponentController(
    val sysRoleComponentService: SysRoleComponentService
) : BaseSysController() {
    companion object {
        const val moduleName = "角色组件关联"
    }

    @Operation(summary = moduleName + "添加")
    @PostMapping("/add.adw")
    fun add(@RequestBody @Validated(Add::class) qo: SysRoleComponentEditQo): RespVo<Long> {
        return sysRoleComponentService.add(qo, getContext())
    }

    @Operation(summary = moduleName + "更新")
    @PostMapping("/update.adw")
    fun update(@RequestBody @Validated(Update::class) qo: SysRoleComponentEditQo): RespVo<Unit> {
        return sysRoleComponentService.update(qo, getContext())
    }

    @Operation(summary = moduleName + "删除")
    @PostMapping("/delete.adw")
    fun delete(@RequestBody @Validated(Delete::class) qo: SysRoleComponentEditQo): RespVo<Unit> {
        return sysRoleComponentService.delete(qo, getContext())
    }

    @Operation(summary = moduleName + "详情")
    @PostMapping("/detail.adw")
    fun detail(@RequestBody @Validated(Detail::class) qo: SysRoleComponentSearchQo): RespVo<SysRoleComponentDetailVo> {
        return sysRoleComponentService.detail(qo, getContext())
    }

    @Operation(summary = moduleName + "列表")
    @PostMapping("/page.adw")
    fun page(@RequestBody @Validated(Page::class) qo: SysRoleComponentSearchQo): RespPageVo<SysRoleComponentListVo> {
        return sysRoleComponentService.page(qo, getContext())
    }

    // [[ OnflowGenerator Range (- selectFunctions -) Start ]]
    @Operation(summary = moduleName + "角色id下拉选")
    @PostMapping("/selectRoleIdList.adw")
    fun selectRoleIdList(@RequestBody qo: SysRoleComponentSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysRoleComponentService.selectRoleIdList(qo, getContext())
    }

    @Operation(summary = moduleName + "组件id下拉选")
    @PostMapping("/selectComponentIdList.adw")
    fun selectComponentIdList(@RequestBody qo: SysRoleComponentSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysRoleComponentService.selectComponentIdList(qo, getContext())
    }

    @Operation(summary = moduleName + "菜单id下拉选")
    @PostMapping("/selectMenuIdList.adw")
    fun selectMenuIdList(@RequestBody qo: SysRoleComponentSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysRoleComponentService.selectMenuIdList(qo, getContext())
    }

// [[ OnflowGenerator Range (- selectFunctions -) End ]]

    @Operation(summary = moduleName + "保存角色和组件关联")
    @PostMapping("/saveRoleRel.adw")
    fun saveRoleRel(@RequestBody eo: SysRoleComponentEditQo): RespVo<Unit> {
        return sysRoleComponentService.saveRoleRel(eo, getContext())
    }

}